home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Games / WHDLoad / Src / slave-examples / oscar.asm < prev    next >
Encoding:
Assembly Source File  |  2001-02-24  |  8.1 KB  |  357 lines

  1. ;*---------------------------------------------------------------------------
  2. ;  :Program.    oscar.asm
  3. ;  :Contents.    Slave for "Oscar"
  4. ;  :Author.    wepl <wepl@whdload.org>
  5. ;  :Original.    v1 Desktop Dynamite <wepl@whdload.org>
  6. ;        v2
  7. ;        v3 CD³²
  8. ;        v4 CD³² Diggers Bundle
  9. ;  :Version.    $Id: oscar.asm 1.11 2001/02/24 22:09:30 jah Exp jah $
  10. ;  :History.    20.05.96
  11. ;        16.06.97 updated for slave version 2
  12. ;        15.08.97 update for key managment
  13. ;        15.07.98 cache on 68040+ disabled
  14. ;        08.05.99 adapted for WHDLoad 10.0, access faults removed
  15. ;        08.12.99 support for v2 added
  16. ;        16.01.00 support for v3 added
  17. ;        23.02.01 support for v4 added, underwater bug fixed
  18. ;  :Requires.    -
  19. ;  :Copyright.    Public Domain
  20. ;  :Language.    68000 Assembler
  21. ;  :Translator.    Barfly V2.9
  22. ;  :To Do.
  23. ;---------------------------------------------------------------------------*
  24.  
  25.     INCDIR    Includes:
  26.     INCLUDE    whdload.i
  27.     INCLUDE    whdmacros.i
  28.     INCLUDE    libraries/lowlevel.i
  29.  
  30.     IFD BARFLY
  31.     ;OUTPUT    "wart:o/oscar/Oscar.Slave"
  32.     ;OUTPUT    "wart:o/oscar cd³²/Oscar.Slave"
  33.     OUTPUT    "wart:o/oscar cd³² bundle/Oscar.Slave"
  34.     BOPT    O+                ;enable optimizing
  35.     BOPT    OG+                ;enable optimizing
  36.     BOPT    ODd-                ;disable mul optimizing
  37.     BOPT    ODe-                ;disable mul optimizing
  38.     BOPT    w4-                ;disable 64k warnings
  39.     SUPER                    ;disable supervisor warnings
  40.     ENDC
  41.  
  42.     STRUCTURE    globals,$100
  43.         LONG    _resload
  44.         LONG    _chipptr
  45.         LONG    _clist
  46.  
  47. ;============================================================================
  48.  
  49. _base        SLAVE_HEADER            ;ws_Security + ws_ID
  50.         dc.w    10            ;ws_Version
  51.         dc.w    WHDLF_NoError        ;ws_flags
  52. _upchip        dc.l    $181000            ;ws_BaseMemSize 
  53.                         ;floppy vers need only $177000
  54.         dc.l    0            ;ws_ExecInstall
  55.         dc.w    _Start-_base        ;ws_GameLoader
  56.         dc.w    _data-_base        ;ws_CurrentDir
  57.         dc.w    0            ;ws_DontCache
  58. _keydebug    dc.b    0            ;ws_keydebug
  59. _keyexit    dc.b    $59            ;ws_keyexit = F10
  60. _expmem        dc.l    $1000            ;ws_ExpMem
  61.         dc.w    _name-_base        ;ws_name
  62.         dc.w    _copy-_base        ;ws_copy
  63.         dc.w    _info-_base        ;ws_info
  64.  
  65. ;============================================================================
  66.  
  67.     IFD BARFLY
  68.     IFND    .passchk
  69.     DOSCMD    "WDate  >T:date"
  70. .passchk
  71.     ENDC
  72.     ENDC
  73.  
  74. _data        dc.b    "data",0
  75. _name        dc.b    "Oscar",0
  76. _copy        dc.b    "1993 Flair Software",0
  77. _info        dc.b    "installed & fixed by Wepl",10
  78.         dc.b    "version 1.8 "
  79.     IFD BARFLY
  80.         INCBIN    "T:date"
  81.     ENDC
  82.         dc.b    0
  83.     EVEN
  84.  
  85. ;============================================================================
  86. _Start        ;    A0 = resident loader
  87. ;============================================================================
  88.  
  89.     ;save resload base
  90.         move.l    a0,(_resload)            ;save
  91.         move.l    a0,a5                ;A5 = resload
  92.  
  93.     ;set stackpointers
  94.         move.l    (_expmem),a7
  95.         add.w    #$f00,a7
  96.  
  97.     ;set start address for emulated exec.AllocMem
  98.         move.l    #$400,(_chipptr)
  99.  
  100.     ;load main
  101.         lea    (_exe,pc),a0            ;name
  102.         move.l    (_chipptr),a1            ;address
  103.         move.l    a1,a4                ;A4 = executable
  104.         jsr    (resload_LoadFileDecrunch,a5)
  105.     ;relocate main
  106.         move.l    a4,a0                ;address
  107.         sub.l    a1,a1                ;taglist
  108.         jsr    (resload_Relocate,a5)
  109.         add.l    d0,(_chipptr)
  110.     ;check version & apply patches
  111.         lea    (_pexe1,pc),a0            ;patchlist
  112.         cmp.l    #$2f2d4,d0
  113.         beq    .patch
  114.         lea    (_pexe2,pc),a0            ;patchlist
  115.         cmp.l    #$2cf58,d0
  116.         beq    .patch
  117.         lea    (_pexe3,pc),a0            ;patchlist
  118.         cmp.l    #$a80d8,d0
  119.         beq    .patch
  120.         lea    (_pexe4,pc),a0            ;patchlist
  121.         cmp.l    #$300a0,d0
  122.         beq    .patch
  123.         pea    TDREASON_WRONGVER
  124.         jmp    (resload_Abort,a5)
  125.         
  126. .patch        move.l    a4,a1                ;address
  127.         jsr    (resload_Patch,a5)
  128.  
  129.     ;init ints
  130.         lea    (_vbi,pc),a0
  131.         move.l    a0,($6c)
  132.         bsr    _SetupKeyboard            ;required for cd versions
  133.  
  134.     ;init dma
  135.         lea    (_clist),a0
  136.         move.l    #-2,(a0)
  137.         move.l    a0,(_custom+cop1lc)
  138.  
  139.     ;start main
  140.         move    #0,sr
  141.         jmp    ($3e,a4)
  142.  
  143. _pexe1        PL_START
  144.         PL_P    $8b4e,_allocmem            ;emulate
  145.         PL_S    $276,$2a8-$276            ;disable os-stuff
  146.         PL_P    $7b1a,_loader
  147.         PL_W    $1ce2,$e841            ;lsr.w  -> asr.w
  148.         PL_W    $1ce4,$c3fc            ;mulu   -> muls
  149.         PL_W    $1cfc,$d0c1            ;adda.l -> adda.w
  150.         PL_W    $1e0e,$e841            ;lsr.w  -> asr.w
  151.         PL_W    $1e10,$c3fc            ;mulu   -> muls
  152.         PL_W    $1e28,$d0c1            ;adda.l -> adda.w
  153.         PL_S    $9764,$99fc-$9764        ;copylock
  154.         PL_PS    $23fa2,_dbf1
  155.         PL_PS    $23fb8,_dbf1
  156.         PL_PS    $246e2,_dbf1
  157.         PL_PS    $246f8,_dbf1
  158.         PL_PS    $2558a,_dbf2
  159.         PL_PS    $255ee,_dbf2
  160.         PL_END
  161.  
  162. _pexe2        PL_START
  163.         PL_P    $8b56,_allocmem            ;emulate
  164.         PL_S    $276,$2a8-$276            ;disable os-stuff
  165.         PL_P    $7b22,_loader
  166.         PL_W    $1cbc,$e841            ;lsr.w  -> asr.w
  167.         PL_W    $1cbe,$c3fc            ;mulu   -> muls
  168.         PL_W    $1cd6,$d0c1            ;adda.l -> adda.w
  169.         PL_W    $1de8,$e841            ;lsr.w  -> asr.w
  170.         PL_W    $1dea,$c3fc            ;mulu   -> muls
  171.         PL_W    $1e02,$d0c1            ;adda.l -> adda.w
  172.         PL_S    $976c,$9a04-$976c        ;copylock
  173.         PL_PS    $21c26,_dbf1
  174.         PL_PS    $21c3c,_dbf1
  175.         PL_PS    $22366,_dbf1
  176.         PL_PS    $2237c,_dbf1
  177.         PL_PS    $2320e,_dbf2
  178.         PL_PS    $23272,_dbf2
  179.         PL_END
  180.  
  181. _pexe3        PL_START
  182.         PL_P    $76fc,_allocmem            ;emulate
  183.         PL_S    $200,$254-$200            ;disable os-stuff
  184.     ;    PL_W    $b48e,$4e73            ;jmp to org vbi -> rte
  185.         PL_S    $750e,$86-$e            ;skip os-restore
  186.         PL_S    $75a8,10            ;skip open
  187.         PL_PS    $75de,_loadercd
  188.         PL_S    $7630,14+$14            ;skip os-save
  189.         PL_PS    $330,_enabledma
  190.         PL_W    $199c,$e841            ;lsr.w  -> asr.w
  191.         PL_W    $199e,$c3fc            ;mulu   -> muls
  192.         PL_W    $19b0,$d0c1            ;adda.l -> adda.w
  193.         PL_W    $1ac2,$e841            ;lsr.w  -> asr.w
  194.         PL_W    $1ac4,$c3fc            ;mulu   -> muls
  195.         PL_W    $1ad6,$d0c1            ;adda.l -> adda.w
  196.         PL_PS    $2d8fc,_dbf1
  197.         PL_PS    $2d912,_dbf1
  198.         PL_PS    $2e03c,_dbf1
  199.         PL_PS    $2e052,_dbf1
  200.         PL_PS    $2eed2,_dbf2
  201.         PL_PS    $2ef36,_dbf2
  202.         PL_END
  203.  
  204. _pexe4        PL_START
  205.         PL_S    $3e,$b4-$3e            ;skip os
  206.         PL_PS    $b4,_getlang
  207.         PL_P    $89ec,_allocmem            ;emulate
  208.         PL_S    $2e0,$326-$2e0            ;disable os-stuff
  209.         PL_S    $797a,$cc-$7a            ;skip os-restore
  210.         PL_S    $79ee,10            ;skip open
  211.         PL_PS    $7a24,_loadercd
  212.         PL_S    $7a54,$68-$54            ;skip os-save
  213.         PL_W    $1ccc,$e841            ;lsr.w  -> asr.w
  214.         PL_W    $1cce,$c3fc            ;mulu   -> muls
  215.         PL_W    $1ce6,$d0c1            ;adda.l -> adda.w
  216.         PL_W    $1df8,$e841            ;lsr.w  -> asr.w
  217.         PL_W    $1dfa,$c3fc            ;mulu   -> muls
  218.         PL_W    $1e12,$d0c1            ;adda.l -> adda.w
  219.         PL_R    $b5c0                ;cd.device
  220.         PL_R    $b614                ;cd.device
  221.         PL_PS    $afe2,_readjoy            ;lowlevel.ReadJoyPort
  222.     ;    PL_PS    $b01e,_readjoy            ;lowlevel.ReadJoyPort
  223.     ;    PL_PS    $b03e,_readjoy            ;lowlevel.ReadJoyPort
  224.     ;    PL_PS    $b060,_readjoy            ;lowlevel.ReadJoyPort
  225.         PL_PS    $22e0c,_dbf1
  226.         PL_PS    $22e22,_dbf1
  227.         PL_PS    $2354c,_dbf1
  228.         PL_PS    $23562,_dbf1
  229.         PL_PS    $243f4,_dbf2
  230.         PL_PS    $24458,_dbf2
  231.         PL_END
  232.  
  233. ;--------------------------------
  234.  
  235. _getlang    clr.l    -(a7)
  236.         clr.l    -(a7)
  237.         pea    WHDLTAG_LANG_GET
  238.         move.l    a7,a0
  239.         move.l    (_resload),a1
  240.         jsr    (resload_Control,a1)
  241.         addq.l    #4,a7
  242.         move.l    (a7)+,d0
  243.         addq.l    #4,a7
  244.         rts
  245.  
  246. ;--------------------------------
  247.  
  248. _dbf2
  249. _dbf1        movem.l    d0-d1,-(a7)
  250.         moveq    #8,d1
  251. .1        move.b    ($dff006),d0
  252. .2        cmp.b    ($dff006),d0
  253.         beq    .2
  254.         dbf    d1,.1
  255.         movem.l    (a7)+,d0-d1
  256.         addq.l    #2,(a7)
  257.         rts
  258.  
  259. ;--------------------------------
  260.  
  261. _vbi        move.w    #INTF_VERTB,(_custom+intreq)
  262.         rte
  263.  
  264. ;--------------------------------
  265.  
  266. _allocmem    addq.l    #7,d0                ;round up
  267.         and.b    #$f8,d0
  268.  
  269.         move.l    (_chipptr),a1
  270.         add.l    d0,(_chipptr)
  271.     IFEQ 1
  272.         move.l    (_chipptr),d1
  273.         cmp.l    (_upchip,pc),d1
  274.         blo    .0
  275.         illegal
  276. .0
  277.     ENDC
  278.         move.l    a1,a0
  279.         lsr.l    #3,d0
  280. .clr        clr.l    (a0)+
  281.         clr.l    (a0)+
  282.         subq.l    #1,d0
  283.         bne    .clr
  284.         move.l    a1,d0
  285.         rts
  286.  
  287. ;--------------------------------
  288.  
  289. _loader        addq.l    #4,a0                ;skip "df0:"
  290.         move.l    a2,-(a7)
  291.         move.l    (_resload),a2
  292.         jsr    (resload_LoadFileDecrunch,a2)
  293.         move.l    (a7)+,a2
  294.         moveq    #0,d0                ;return code
  295.         rts
  296.  
  297. _loadercd    addq.l    #6,a0                ;skip "Oscar:"
  298.         move.l    d2,a1
  299.         move.l    (_resload),a2
  300.         jsr    (resload_LoadFileDecrunch,a2)
  301.         add.l    #14,(a7)
  302.         rts
  303.  
  304. ;--------------------------------
  305.  
  306. _enabledma    move.w    #$c028,(intena,a6)
  307.         waitvb    a6
  308.         move.w    #$86e0!DMAF_RASTER,(dmacon,a6)
  309.         rts
  310.  
  311. ;--------------------------------
  312.  
  313. _readjoy    move.l    d2,-(a7)
  314.  
  315.         moveq    #0,d0
  316.         btst    #7,$bfe001
  317.         bne    .1
  318.         bset    #JPB_BUTTON_RED,d0
  319. .1        move.w    _custom+potinp,d1
  320.         btst    #14,D1
  321.         bne    .2
  322.         bset    #JPB_BUTTON_BLUE,d0
  323. .2
  324.         move.w    _custom+joy1dat,d1
  325.         move.w    d1,d2
  326.         btst    #1,d1
  327.         beq    .left_off
  328.         bset    #JPB_JOY_RIGHT,d0
  329.         bra    .vert_test
  330. .left_off    btst    #9,d1
  331.         beq    .vert_test
  332.         bset    #JPB_JOY_LEFT,d0
  333. .vert_test    lsr.w    #1,d1
  334.         eor.w    d2,d1
  335.         btst    #0,d1
  336.         beq    .back_off
  337.         bset    #JPB_JOY_DOWN,d0
  338.         bra    .exit
  339. .back_off    btst    #8,d1
  340.         beq    .exit
  341.         bset    #JPB_JOY_UP,d0
  342. .exit
  343.         move.l    (a7)+,d2
  344.         rts
  345.  
  346. ;--------------------------------
  347.  
  348. _exe        dc.b    "exe",0
  349.  
  350. ;============================================================================
  351.  
  352.         INCLUDE    sources:whdload/keyboard.s
  353.  
  354. ;============================================================================
  355.  
  356.     END
  357.